package leetcode.medium.limit100;

import java.util.Arrays;

/**
 * @author yaoyao1.liu@zhaopin.com.cn
 * @since 2022-11-11 14:15
 **/
public class No75 {
    public static void main(String[] args) {
        No75 no75 = new No75();
        int[] nums = new int[]{0,1};
        no75.sortColors(nums);
        System.out.println(Arrays.toString(nums));
    }

    public void sortColors(int[] nums) {
        if (nums.length == 1 || nums.length == 0) {
            return;
        }
        int prt = 0;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] == 0) {
                int temp = nums[i];
                nums[i] = nums[prt];
                nums[prt] = temp;
                ++prt;
            }
        }
        for (int i = prt; i < nums.length; i++) {
            if (nums[i] == 1) {
                int temp = nums[i];
                nums[i] = nums[prt];
                nums[prt] = temp;
                prt++;
            }
        }
    }
}
